<template>
  <el-timeline v-if="activities && activities.length > 0" class="business-action">
    <el-timeline-item
      placement="top"
      v-for="(activity, index) in activities"
      :key="index"
      :type="activity.type"
      :timestamp="useTime(activity.optDate).nowTime.value"
    >
      <el-card>
        {{ activity.optInfo }}
      </el-card>
    </el-timeline-item>
  </el-timeline>
  <span v-else>暂时没有记录~~</span>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import apiService from "@/api/services/apiService";
import { UserAction } from "@/api/types/base";
import { useTime } from "@/hooks/useTime";

const activities = ref<UserAction[]>();

interface SelectFilterProps {
  businessId?: string;
}
const props = defineProps<SelectFilterProps>();

onMounted(() => {
  getDataList();
});

const getDataList = async () => {
  if (props.businessId) {
    let { data } = await apiService.find<UserAction[]>("userAction", { businessId: props.businessId });
    activities.value = data;
  }
};
</script>

<style scoped lang="scss">
.business-action {
  width: 100%;
  padding-left: 5px !important;
}
</style>
